from django.shortcuts import render
from django.http import HttpResponse, JsonResponse

from carlargescreen.utils.get_centerdata import get_centerdata, get_rolldata, get_ratedata
from carlargescreen.utils.get_centerleftdata import get_centerleft
from carlargescreen.utils.get_bottomleftdata import get_bottomleft
from carlargescreen.utils.get_bottomrightdata import get_bottomright
from carlargescreen.utils.get_centerright2 import get_centerright2
from carlargescreen.utils.get_centerright import get_centerright



def center(request):
    if request.method == "GET":
        sum_car, highvolume_car, highcount, most_model, most_brand, avg_price = get_centerdata()
        rolldata_list = get_rolldata()
        qiyou_rate, chundian_rate, other_rate = get_ratedata()
        data = {
            "sum_car": sum_car,
            "highvolume_car": highvolume_car,
            "highcount": highcount,
            "most_model": most_model,
            "most_brand": most_brand,
            "avg_price": avg_price,
            "rolldata_list": rolldata_list,
            "qiyou_rate": qiyou_rate,
            "chundian_rate": chundian_rate,
            "other_rate": other_rate,
        }
        return JsonResponse(data)


def centerleft(request):
    if request.method == "GET":
        leftxdata_list, leftseries_list = get_centerleft()
        data = {
            "leftxdata_list": leftxdata_list,
            "leftseries_list": leftseries_list,
        }
        return JsonResponse(data)


def bottomleft(request):
    if request.method == "GET":
        carname_list, carcount_list, caravgprice_list = get_bottomleft()
        data = {
            "carname_list": carname_list,
            "carcount_list": carcount_list,
            "caravgprice_list": caravgprice_list
        }
        return JsonResponse(data)


def bottomright(request):
    if request.method == "GET":
        carinfo_list = get_bottomright()
        data = {
            "carinfo_list": carinfo_list,
        }
        return JsonResponse(data)


def centerright2(request):
    if request.method == "GET":
        format_list = get_centerright2()
        data = {
            "format_list": format_list
        }
        return JsonResponse(data)


def centerright1(request):
    if request.method == "GET":
        you_list, dian_list, other_list = get_centerright()
        data = {
            "you_list": you_list,
            "dian_list": dian_list,
            "other_list": other_list,
        }
        return JsonResponse(data)